﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using HeinQi.Framework.DataAccess;
using TbShop.Entity;

namespace TbShop.Data.Components
{
    public class TbShopDBContext : BaseDbContext
    {
        private static TbShopDBContext instance;
        private static readonly object locker = new object();

        public TbShopDBContext()
            : base("Default")
        {
            //this.Database.CreateIfNotExists();
        }


        public static TbShopDBContext GetInstance()
        {
            //if (instance == null)
            //{
            //    lock (locker)
            //    {
            //        if (instance == null)
            //        {
            //            instance = new CIRevolutionDbContext();
            //        }
            //    }
            //}
            //return instance;
            return new TbShopDBContext();
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
        }

        public static void ClearInstance()
        {
            if (instance != null)
            {
                lock (locker)
                {
                    if (instance != null)
                    {
                        instance = null;
                    }
                }
            }
        }

        public DbSet<T> GetSets<T>()
         where T : class
        {
            return this.Set<T>();
        }

        public IDbSet<AspNetUserRoles> AspNetUserRoles { set; get; }

        public IDbSet<SiteMap> SiteMaps { get; set; }

        public IDbSet<Authority> Authoritys { get; set; }

        public IDbSet<CodeTable> CodeTables { get; set; }

        public IDbSet<RoleAuthority> RoleAuthoritys { get; set; }

        public IDbSet<OperationLog> OperationLogs { get; set; }

        public IDbSet<AspNetRoles> AspNetRoles { get; set; }

        public IDbSet<LoginLog> LoginLogs { get; set; }

        public IDbSet<AspNetUsers> AspNetUsers { get; set; }

        public IDbSet<TbCategory> TbCategorys { get; set; }
        

        #region haitao

        public IDbSet<Banner> Banners { get; set; }

        public IDbSet<SystemMessage> SystemMessages { get; set; }
        
        #endregion

        #region jinli

        #endregion

        #region jinting

        #endregion

        #region runhua
        #endregion

    }
}


